package MallCoreStatistics

import (
	CoreSQL "gitee.com/fotomxq/weeekj_core/v5/core/sql"
	Router2SystemConfig "gitee.com/fotomxq/weeekj_core/v5/router2/system_config"
)

type ArgsUpdateStatistics struct {
	//组织ID
	OrgID int64 `db:"org_id" json:"orgID"`
	//用户ID
	UserID int64 `db:"user_id" json:"userID"`
	//订单等待id
	OrderWaitID int64 `db:"order_wait_id" json:"orderWaitID"`
	//订单id
	OrderID int64 `db:"order_id" json:"orderID"`
}

// UpdateStatistics 更新统计数据得订单id
func UpdateStatistics(args *ArgsUpdateStatistics) (err error) {
	_, err = CoreSQL.UpdateOne(Router2SystemConfig.MainDB.DB, "UPDATE mall_core_statistics SET order_id=:order_id ,is_effective_stats = 1 WHERE order_wait_id=:order_wait_id and org_id=:org_id and user_id = :user_id",
		map[string]interface{}{
			"order_wait_id": args.OrderWaitID,
			"org_id":        args.OrgID,
			"user_id":       args.UserID,
			"order_id":      args.OrderID,
		})
	return
}
